package homework;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Stream;

public class Test05 {
	public static void main(String[] args) {
		Integer[] arr1 = {1,2,3,3}, arr2={3,4,5,2};
		System.out.println(unique(arr1,arr2));
	}
	
	private static String unique(Integer[] arr1, Integer[] arr2) {
		Set<Integer> set1 = new HashSet<>();
		Set<Integer> set2 = new HashSet<>();
        Stream.concat(Arrays.stream(arr1), Arrays.stream(arr2))
            .forEach(num -> {
                if (set1.contains(num)) {
                    set1.remove(num);
                    set2.add(num);
                } else {
                    if(!set2.contains(num)) set1.add(num);
                }
            });
        return Arrays.toString(set1.toArray());
    }
}
